#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    :  
# @function: 
# @version :


import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys  # 模拟键盘操作


browser = webdriver.Chrome()
browser.get('https://www.baidu.com')
# 不加s选择一个元素，根据属性name取值
# s = browser.find_element(By.NAME, 'wd')
# 根据id选择元素
# s = browser.find_element(By.ID, 'kw')
# s.send_keys('micah真帅')
# css选择器
s = browser.find_element(By.CSS_SELECTOR, '.s_ipt')
s.send_keys('micah真帅')
s.send_keys(Keys.ENTER)
# xpath选择
browser.find_element(By.XPATH, '//*[@id="kw"]')

time.sleep(2)
browser.quit()